package com.okaixz.client.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.okaixz.client.model.domain.User;
import com.okaixz.client.model.dto.*;
import com.okaixz.client.model.vo.GetOpenIdResult;
import com.okaixz.common.client.vo.WxAppPayParams;
import com.okaixz.common.client.vo.WxMiniProgramPayClientReqeust;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 * APP用户信息表 服务类
 * </p>
 *
 * @author cdz
 * @since 2024-10-08
 */
public interface IWxService extends IService<User> {

    @Transactional
    UserDto processWxQrcodeLoginCallBack(String code, String state);

    String getQrcode(String sid);

    /**
     * pc端获取微信支付二维码
     * @param userId
     * @param gid
     * @return
     */
    String getWxPayCode(String userId, Integer gid,String sessionId);

    /**
     * 微信小程序端发起支付请求
     * @param userId
     * @param gid
     * @return
     */
    WxMiniProgramPayClientReqeust wxMiniProgramCreateOrder(String userId, Integer gid, String sessionId);

    /**
     * 处理微信扫码支付回调
     * @param request
     * @param response
     * @return
     */
    String processNativePayCallback(HttpServletRequest request, HttpServletResponse response);
    /**
     * 处理微信app支付回调
     * @param request
     * @param response
     * @return
     */
    String processAppPayCallback(HttpServletRequest request, HttpServletResponse response);
    /**
     * 获取access_token 先从缓存中取如果没有再从微信取
     */
    String getAccessToken();
    /**
     * 获取带参数的二维码
     */
    String getQrcodeWithParams(String eventKey,String type);

    /**
     * 处理公众号消息
     */
    void onMessage(WxMessage wxMessage);

    /**
     * 微信小程序登录
     * @param code
     * @return
     */
    UserDto wxMiniprogramLogin(String code,String shareUserId);

    /**
     * 获取微信小程序openId
     * @param code
     * @return
     */
    GetOpenIdResult getOpenId(String code);

    /**
     * 通过code获取access_token
     */
    WxAccessTokenResult getAccessToken(GetAccessTokenParams params);
    /**
     * 通过accesstoken和openid获取用户信息
     */
    WxUserInfo getUserInfo(String accessToken,String openId);

    /**
     * 获取微信app支付参数 会创建定单
     * @param userId
     * @param gid
     * @return
     */
    WxAppPayParams wxAppCreateOrder(String userId, Integer gid, String sessionId);

}
